package com.ruoyi.interview.service.impl;


import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.interview.domain.IntervWay;
import com.ruoyi.interview.mapper.IntervWayMapper;
import com.ruoyi.interview.service.IIntervInfoService;
import com.ruoyi.interview.service.IIntervWayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-08
 */
@Service
public class IntervWayServiceImpl implements IIntervWayService
{
    @Resource
    private IntervWayMapper intervWayMapper;
    @Autowired
    private IIntervInfoService intervInfoService;


    /**
     * 查询
     * 
     * @param wId 主键
     * @return
     */
    @Override
    public IntervWay selectIntervWayByWId(Long wId)
    {
        return intervWayMapper.selectIntervWayByWId(wId);
    }

    /**
     * 查询列表
     * 
     * @param intervWay
     * @return
     */
    @Override
    public List<IntervWay> selectIntervWayList(IntervWay intervWay)
    {
        return intervWayMapper.selectIntervWayList(intervWay);
    }

    /**
     * 新增
     * 
     * @param intervWay
     * @return 结果
     */
    @Override
    public int insertIntervWay(IntervWay intervWay)
    {
        intervWay.setCreateTime(DateUtils.getNowDate());
        return intervWayMapper.insertIntervWay(intervWay);
    }

    /**
     * 修改
     * 
     * @param intervWay
     * @return 结果
     */
    @Override
    public int updateIntervWay(IntervWay intervWay)
    {
        intervWay.setUpdateTime(DateUtils.getNowDate());
        return intervWayMapper.updateIntervWay(intervWay);
    }

    /**
     * 批量删除
     * 
     * @param wIds 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteIntervWayByWIds(Long[] wIds)
    {
        int Wid = intervInfoService.updateIntervWid(wIds);
        if (!(Wid>0)){
            throw new GlobalException("删除失败");
        }
        return intervWayMapper.deleteIntervWayByWIds(wIds);
    }

    /**
     * 删除信息
     * 
     * @param wId 主键
     * @return 结果
     */
    @Override
    public int deleteIntervWayByWId(Long wId)
    {
        return intervWayMapper.deleteIntervWayByWId(wId);
    }

    @Override
    public Long selectIdByWay(String way) {
        return intervWayMapper.selectIntervIdByWay(way);
    }
}
